package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.rm.zeyou.entity.User;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.UserMemberOrderService;
import com.rm.zeyou.util.login.LoginUtil;
import com.rm.zeyou.vo.request.OpenMemberVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 用户会员表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:09
 */
@Api(tags = "会员订单相关")
@RestController
@RequestMapping("/api/userMemberOrder")
public class UserMemberOrderController {
    @Resource
    private UserMemberOrderService userMemberOrderService;
    @Resource
    private LoginUtil loginUtil;

    @ApiOperation("开通会员")
    @PostMapping("openMember")
    @SaCheckLogin(type = "user")
    public ApiRestResponse openMember(@RequestBody OpenMemberVo openMemberVo) throws Exception {
        User user = loginUtil.getUser();
        return userMemberOrderService.openMember(user,openMemberVo);
    }
}
